{% extends "base.html" %}

{% block page_title %}
    <h2>{{ post.title }}</h2>
{% endblock page_title %}

{% block page_content %}
    <small>
        {{ post.created_on.date }} | Categories:
        {% for category in post.categories.all %}
            <a href="{% url 'blog_category' category.name %}">
                {{ category.name }}
            </a>
        {% endfor %}
    </small>
    <p>{{ post.body | linebreaks }}</p>

    <h3>Leave a comment:</h3>
    <form method="post">
        {% csrf_token %}
        <div class="form-group">
            {{ form.author }}
        </div>
        <div class="form-group">
            {{ form.body }}
        </div>
        <button type="submit" class="btn btn-primary">Submit</button>
    </form>

    <h3>Comments:</h3>
    {% for comment in comments %}
        <p>
            On {{ comment.created_on.date }} <b>{{ comment.author }}</b> wrote:
        </p>
        <p>
            {{ comment.body | linebreaks }}
        </p>
    {% endfor %}
{% endblock page_content %}
